package Text48;

import java.util.*;

public class Main {
    static int N = 1010, n = 1;
    static int[] a = new int[N];
    static int[] f = new int[N];
    static int[] g = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            a[n++] = in.nextInt();
        }
        n--;
        int res = 0;
        for (int i = n; i >= 1; i--) {
            f[i] = 1;
            for (int j = n; j > i; j--) {
                if (a[i] >= a[j]) {
                    f[i] = Math.max(f[i], f[j] + 1);
                }
            }
            res = Math.max(res, f[i]);
        }
        int cnt = 0;
        for (int i = n; i >= 1; i--) {
            int k = 0;
            while (k < cnt && g[k] > a[i]) {
                k++;
            }
            g[k] = a[i];
            if (k >= cnt) {
                cnt++;
            }
        }
        System.out.println(res);
        System.out.println(cnt);
    }
}
